package com.polaris.live.viewmodel

import androidx.lifecycle.MutableLiveData
import com.polaris.live.net.userService
import com.polaris.live.resp.base.ListResp
import com.polaris.live.widget.refresh.OnListListener
import com.polaris.live.common.mvvm.viewmodel.BaseViewModel
import com.polaris.live.common.network.request
import com.polaris.live.common.network.state.ResultState
import com.polaris.live.im.sfs.bean.live.ext.UserBasicVo

/**
 * 关注
 */
class FollowViewModel : BaseViewModel(), OnListListener {

    var followersLiveData = MutableLiveData<ResultState<ListResp<UserBasicVo>>>()

    val pageSize = 20  // 每页记录数

    private fun getFollowers(pageNumber: Int, pageSize: Int = this.pageSize) {
        request({ userService.getFollowers(pageNumber, pageSize) }, followersLiveData)
    }

    override fun onRefresh() {
        getFollowers(pageNumber = 0)
    }

    override fun onLoadMore(pageIndex: Int) {
        getFollowers(pageNumber = pageIndex)
    }

}